package com.hcyy.util;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.hcyy.dao.UserDao;
import com.hcyy.entity.User;

@Repository
public class UserUtil {
	@Autowired
	private UserDao userDao;
	public  User findUser(HttpServletRequest request){
		try {
			User user=(User)request.getSession().getAttribute("user");
			Integer sjid=(Integer) request.getSession().getAttribute("sjid");
			String uname=user.getUsername();
			User u=userDao.findUserByUserName(uname, sjid);
			return null==u?null:u;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
}
